<div id="uploadChart" style="width: 100%;height:600px;"></div> 
<script src="/echarts/echarts.common.min.js"></script>
<script type="text/javascript">
    Dcat.ready(function () {
        var uploadChart = echarts.init(document.getElementById('uploadChart'));
        let data = [];
        let ss = {};
        let xData = [];
        let legend = [];

        var option;
        option = {
          title: {
            text: ''
          },
          tooltip: {
            trigger: 'axis'
          },
          legend: {
            data: legend
          },
          grid: {
            left: '3%',
            right: '4%',
            bottom: '3%',
            containLabel: true
          },
          xAxis: {
            type: 'category',
            boundaryGap: false,
            data: xData
          },
          yAxis: {
            type: 'value'
          },
          series: data,
          dataZoom: [
                {
                  type: 'slider',
                  show: true,
                }
            ]
        };

        option && uploadChart.setOption(option);
        let nowPage = 1;
        initChart(nowPage);

        function initChart(nowPage) {
            console.log(nowPage);
          let url = "{{ URL::asset('admin/getUploadChart') }}";
          let postData = {
                _token: '{{ csrf_token() }}',
                key: '{{ $key }}',
                page: nowPage
            }
            $.ajax({
                type : "POST",
                url : url,
                data : postData,
                success : function(result) {
                    console.log(result)
                    if (result.code == 1) {
                        if (nowPage == 1) {
                            data = result.data.series.series;
                            xData = result.data.series.xData;
                            legend = result.data.legend;
                            uploadChart.setOption({
                                legend: {
                                    data: legend
                                },
                                xAxis: {
                                    data: xData
                                  },
                                series: data,
                              });
                            initChart(nowPage+1);
                        } else {
                            for (let k in data) {
                                data[k].data = data[k].data.concat(result.data.series.series[k].data)
                            }
                            xData = xData.concat(result.data.series.xData);
                            uploadChart.setOption({
                                xAxis: {
                                  data: xData
                                },
                                series: data
                              });
                            initChart(nowPage+1);
                        }
                    } else {
                        initChart(nowPage);
                    }
                },
                //请求失败，包含具体的错误信息
                error : function(e){
                    layer.close(e);
                    console.log(e.status);
                    console.log(e.responseText);
                }
            });
        }

    });
</script>